package com.ciwong.epaper.modules.viedoexplantion;

import android.content.Context;
import android.view.View;

import com.ciwong.epaper.modules.viedoexplantion.imp.BlankLoadUi;
import com.ciwong.epaper.modules.viedoexplantion.imp.ChoiceLoadUi;
import com.ciwong.epaper.modules.viedoexplantion.imp.ChoiceMoreLoadUi;
import com.ciwong.epaper.modules.viedoexplantion.imp.CloseBlankLoadUi;
import com.ciwong.epaper.modules.viedoexplantion.imp.MuiltLoadUi;
import com.ciwong.epaper.modules.viedoexplantion.imp.ReadLoadUi;
import com.ciwong.epaper.modules.viedoexplantion.imp.ShortLoadUi;
import com.ciwong.epaper.modules.viedoexplantion.imp.TitleLoadUi;
import com.ciwong.epaper.modules.viedoexplantion.imp.WriteLoadUi;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by young on 2016/7/5.
 * 加载不同试图控制类
 */
public final class LoadUiImp {
    private static  final String  TAG=LoadUiImp.class.getSimpleName();
    private static final List<Class<? extends LoadUi>> LOADUIS=new LinkedList<Class<? extends LoadUi>>();
    static {
        LOADUIS.add(BlankLoadUi.class);
        LOADUIS.add(ChoiceLoadUi.class);
        LOADUIS.add(MuiltLoadUi.class);
        LOADUIS.add(ReadLoadUi.class);
        LOADUIS.add(ShortLoadUi.class);
        LOADUIS.add(TitleLoadUi.class);
        LOADUIS.add(WriteLoadUi.class);
    }

    private static LoadUi sLoadUi;
    //加载布局统一方法
    public static View loadLayout(Object  o, int type, Context context,Boolean b){
        View view=null;
        try {
            initLoadUi(type);
            view= sLoadUi.loadLayout(o,context,b);
        }catch (Exception e){
            e.getStackTrace();
        }
    return view;
    }
    //初始化UI加载器
    private static void initLoadUi(int type){
        switch (type){
            case   QuestionType.QUESTION_TYPE_CHOICE:
                sLoadUi=new ChoiceLoadUi();
                break;
            case   QuestionType.QUESTION_TYPE_ChooseMore:
                sLoadUi=new ChoiceMoreLoadUi();
                break;

            case   QuestionType.QUESTION_TYPE_FILL_BLANK:
                sLoadUi=new BlankLoadUi( );
                break;
            case   QuestionType.QUESTION_TYPE_READ:
                sLoadUi=new ReadLoadUi();
                break;
            case   QuestionType.QUESTION_TYPE_SHORT:
                sLoadUi=new ShortLoadUi();
                break;
            case   QuestionType.QUESTION_TYPE_MUILT:
                sLoadUi=new MuiltLoadUi();
                break;
            case   QuestionType.QUESTION_TYPE_WRITE:
                sLoadUi=new WriteLoadUi();
                break;
            case   QuestionType.QUESTION_TYPE_FILL_CLOSE_BLANK:
                sLoadUi=new CloseBlankLoadUi();
                break;


        }
    }

}

